package com.fenxiangtech.mall.service.impl;

import com.fenxiangtech.mall.service.ImageService;
import com.fenxiangtech.mall.dao.BannerItemDao;
import com.fenxiangtech.mall.entity.BannerItem;
import com.fenxiangtech.mall.entity.Image;
import com.fenxiangtech.mall.service.BannerItemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhangjiashun
 */
@Service
public class BannerItemServiceImpl implements BannerItemService {

    @Autowired
    private BannerItemDao bannerItemDao;

    @Autowired
    private ImageService imageService;

    @Override
    public List<BannerItem> listBannerItemByBannerId(Long bannerId) {
        List<BannerItem> bannerItems = bannerItemDao.listBannerItemByBannerId(bannerId);
        for (BannerItem bannerItem : bannerItems) {
            Image image = imageService.getImageById(bannerItem.getImage().getId());
            bannerItem.setImage(image);
        }
        return bannerItems;
    }
}
